package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/5/27 09:39
 * @apiNote
 */

public class Test02028MissingRolls {
    public int[] missingRolls(int[] rolls, int mean, int n) {
        int m = rolls.length;
        int sum = mean *(m+n);
        int misssinSum = sum;
        for(int i =0 ; i<m;i++){
            misssinSum -= rolls[i];
        }
        if(misssinSum<n || misssinSum>6*n){
            return new int[0];
        }
        int avg = misssinSum / n;
        int remainder = misssinSum % n;
        int[] res = new int[n];
        for(int i = 0;i <n;i++){
            res[i] = avg +(i < remainder ? 1:0);
        }
        return res;
    }
}
